void game :: set_target (short emit, short target)
{ Characters[emit].target = target; }
void game :: init()
{
    //character_s ch;
    string names[4] = {"Dande", "Nonffe", "Barnaby", "Penus"};
    //
    //Vector2f vecs[4] =
    //{
    //    Vector2f(0,10),
    //    Vector2f(5,10),
    //    Vector2f(5,5),
    //    Vector2f(5,0)
    //};
    FOR(4)
    {
        Characters.push_back(character_s());
        CharNames.push_back(names[i]);
        //CharPositions.push_back(vecs[i]);
    }
    click_position = Vec3();
#ifdef USE_YAML
    load_abilities();
#endif
    Ogre::ConfigFile cf;
    cf.load(PATH+"conf/ui.cfg");
    int x, y, w, h;
    float vertical;
    istringstream iss(cf.getSetting("cast_bar"));
    iss >> w >> h >> vertical;
    x = (appli->viewport -> getActualWidth() - w) / 2;
    y = appli->viewport -> getActualHeight() * vertical;

    bar.width = w;
    bar.frame = appli->gor_layer -> createRectangle(Vec2(x,y),Vec2(w,h));
    bar.progress = appli->gor_layer -> createRectangle(Vec2(x,y), Vec2(w,h));
    bar.frame->border(2.0f, bar.border);
    bar.frame->background_colour(bar.empty);
    bar.progress->background_colour(bar.filled);
}
#ifdef USE_YAML
void game :: load_abilities()
{
    // getting spell name list
    //Ogre::ConfigFile cf;
    //cf. CROSSLOAD("conf/abils.cfg");

    ynode doc;
    ifstream ifstr(PATH+"conf/abils.yml");
    YAML::Parser parser(ifstr); // remember to pass it by reference
    if(! parser.GetNextDocument(doc))
        exit(0xbadf00d);

    ability base;
    for(YAML::Iterator a = doc.begin(); a != doc.end(); ++ a)
    {
        string name(get_scalar((*a).begin().first()));
        string parsee = get_scalar((*a).begin().second());
        //Ogre::StringVector strs = StringUtil::split(parsee);
        //for(StringVector::iterator it = strs.begin(); it != strs.end(); ++it)
        //{
        cout << parsee << endl;
        istringstream iss(parsee);
        if(iss)
        {
            memset(&base, 0, sizeof(base));
            string misl, cone, bell, chain;
            short ticks, radius, velocity, range;

            // unwrapping as usual, works better than split: split cannot deal with multi-spaces eg "  ".
            //misl cone bell chain delay ticks rad veloc
            iss >> misl >> cone >> bell >> chain
                >> base.cooltime
                >> ticks >> radius >> velocity >> range;
            base.ticks    = ticks    ;
            base.range    = range    ;
            base.radius   = radius   ;
            base.velocity = velocity ;
            if(misl  == "ye") set_mask8(base.mask, MISSILE); else set_mask8(base.mask, MISSILE, false);
            if(cone  == "ye") set_mask8(base.mask, CONIC  ); else set_mask8(base.mask, CONIC  , false);
            if(bell  == "ye") set_mask8(base.mask, BELL   ); else set_mask8(base.mask, BELL   , false);
            if(chain == "ye") set_mask8(base.mask, CHAIN  ); else set_mask8(base.mask, CHAIN  , false);

            if (base.cooltime == 0.f)
                base.cooltime = -1.f; 
            
            Abilities.push_back(base);

            AbilIds[name] = Abilities.size() - 1;
            AbilNames.push_back(name);
        }
    }
    
    for(std::vector<ability>::iterator a = Abilities.begin(); a!=Abilities.end(); ++a)
    {
        ostringstream iss;
        //cout 
        iss
        << AbilNames[std::distance(Abilities.begin(), a)] << "\t"
        << a->cooltime << " "
        << short(a->radius) << " "
        << short(a->ticks) << " "
        << short(a->range) << " "
        << short(a->velocity) << " "
        << inspect_mask(a->mask) <<
        endl;
        LOGMSG(iss.str());
        
    }
    ostringstream oss;
    //cout
    oss
    //<< "Abilities AbilNames CharNames Characters CharPositions Timers avail" << endl 
    << "Abilities " << Abilities.size() << " "
    << "AbilNames " << AbilNames.size() << " "
    << "CharNames " << CharNames.size() << " "
    << "Characters " << Characters.size() << " "
   // << "CharPositions " << CharPositions.size() << " "

    << "Timers " << Timers.size() << " "
    //<< "availables " << availables.size() << " "
    
    << endl;
    LOGMSG(oss.str());
}
#endif